package com.book.controller;

import com.book.entity.Carousel;
import com.book.service.CarouselService;
import com.book.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * @author yicheng
 */
@RestController
@RequestMapping("/carousel")
public class CarouselController {
    @Autowired
    private CarouselService carouselService;

    @GetMapping("/getCarousel")
    public ResponseResult getCarousel(){
        return carouselService.getCarousel();
    }

    @GetMapping("/getCarouselOne")
    public ResponseResult getCarouselOne(@RequestParam int id){
        return carouselService.getCarouselOne(id);
    }

    @GetMapping("/deleteCarousel")
    public ResponseResult deleteCarousel(@RequestParam int id){
        return carouselService.deleteCarousel(id);
    }


    /**
     * 保存轮播图信息，编辑或添加
     * @param carousel
     * @return
     */
    @PostMapping("/saveCarousel")
    public ResponseResult saveCarousel(@RequestBody Carousel carousel){
        return carouselService.saveCarousel(carousel);
    }


}
